import { createBrowserRouter, Navigate, Outlet } from 'react-router-dom';
import Main from '../pages/main/index';
import Home from '../pages/Home/index';
import User from '../pages/User/index';
import NotFound from '../pages/NotFound';
import Role from '../pages/Role';
import Login from '../pages/Login/index';
import { PrivateRoute } from './PrivateRoute';

const router = createBrowserRouter([
  {
    path: '/',
    element: <PrivateRoute />,
    children: [
      {
        path: '/',
        element: <Main />,
        children: [
          {
            path: '/',
            element: <Navigate to="/home" />,
          },
          {
            path: 'home',
            element: <Home />,
          },
          {
            path: 'user',
            element: <User />,
          },
          {
            path: 'user/role',
            element: <Role />,
          }
        ]
      }
    ]
  },
  {
    path: '/login',
    element: <Login />
  },
  {
    path: '/404',
    element: <NotFound />
  },
  {
    path: '*',
    element: <Navigate to="/404" replace />
  }
]);

export default router;